<div class="bg-light lter b-b wrapper-md ng-scope">
    <h4 class="m-n font-thin">客户管理</h4>
</div>
<div class="wrapper-md ng-scope" ng-controller="clientCtrl">
    <div class="panel panel-default">
        <div class="row wrapper">
            <div class="col-sm-9">
                <form class="form-inline ng-pristine ng-valid">
                    <div class="form-group">
                        <label class="control-label h6">联系方式</label>
                        <input type="text" class="input-sm form-control" ng-model="client.mobilePhone">
                    </div>
                    <div class="form-group">
                        <label class="control-label h6">会员卡号</label>
                        <input type="text" class="input-sm form-control" ng-model="client.cardNumber">
                    </div>
                    <div class="form-group">
                        <label class="control-label h6">客户身份</label>
                        <select class="input-sm form-control" ng-model="client.clientStatus">
                            <option value>全部</option>
                            <option value="0">非会员</option>
                            <option value="1">会员</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="control-label h6">会员卡</label>
                        <select class="input-sm form-control" ng-model="client.memberCardId">
                            <option value ng-click="clear()">全部</option>
                            <option ng-repeat="m in memberCardVO" value="{{m.id}}">{{m.cardName}}</option>
                        </select>
                    </div>
                    <button class="btn btn-sm btn-default" ng-click="query()">查询</button>
                </form>
            </div>
            <div class="col-sm-3 pull-right m-b-sm" ng-if="checkType==1">
                <div class="pull-right">
                    <button class="btn btn-sm btn-info" ng-click="reserved()" popover-placement="bottom"
                            popover="作用：预留会员编号后,可用于发放实体会员卡时进行绑定使用！" popover-trigger="mouseenter">预留会员编号
                    </button>
                </div>
            </div>
        </div>
        <div class="table-responsive">
            <table class="table table-striped b-t b-light">
                <thead>
                    <tr>
                        <th>客户信息</th>
                        <th>会员卡</th>
                        <!--<th>会员等级</th>-->
                        <th>可用资产</th>
                        <th>消费记录</th>
                        <th>客户身份</th>
                        <th>时间</th>
                        <th width="200" class="text-center">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="item in list">
                        <td class="h5">
                            <span>昵称：{{item.nickName}}<br></span>
                            <span>联系方式：{{item.mobilePhone}}</span>
                        </td>
                        <td class="h5" ng-if="item.memberCardName!=null">
                            <span>{{item.memberCardName}}<br></span>
                            <span ng-if="item.cardNumber!=null">(会员编号：{{item.cardNumber}})</span>
                        </td>
                        <td class="h5" ng-if="item.memberCardName==null">
                            <span>暂无会员卡<br></span>
                            <span ng-if="item.cardNumber!=null">(会员编号：{{item.cardNumber}})</span>
                        </td>
                        <td class="h5">
                            <span>可用余额：{{item.balance | number:2}} 元<br></span>
                            <span>当前积分：{{item.nowIntegral}} 分</span>
                        </td>
                        <td class="h5">
                            <span>购买次数：{{item.buyCount}} 次<br></span>
                            <span>累计消费：{{item.consumePrice | number:2}} 元<br></span>
                            <span>累计积分：{{item.consumeIntegral}} 分</span>
                        </td>
                        <td class="h5" ng-if="item.clientStatus==0">非会员</td>
                        <td class="h5" ng-if="item.clientStatus==1">会员</td>
                        <td class="h5">
                            <sapn>成为客户时间：{{item.clientDate.split(" ")[0]}}</sapn><br>
                            <span ng-if="item.memberDate != null">成为会员时间：{{item.memberDate.split(" ")[0]}}</span><br>
                            <span ng-if="item.memberEndDate != null">会员过期时间：{{item.memberEndDate.split(" ")[0]}}</span>
                        </td>
                        <td>
                            <button class="btn btn-primary m-b-xs" ng-if="item.clientStatus==0" ng-click="upgrade(item.id)">升级会员</button>
                            <button class="btn btn-info m-b-xs" ng-if="item.clientStatus==1" ng-click="update(item.id)">设置会员</button>
                            <button class="btn btn-success m-b-xs" ng-if="item.clientStatus==1" ng-click="charge(item.id)">在线储值</button>
                            <button class="btn btn-danger m-b-xs" ng-click="giveCoupons(item.id)">送优惠卷</button>
                        </td>
                    </tr>
                </tbody>
            </table>
            <div ng-if="list.length<=0 && !app.loading" class="padder-v text-center">
                <span class="h6">~未搜索到任何数据~</span>
            </div>
            <div>
                <circle-loading ng-if="app.loading"></circle-loading>
            </div>
        </div>
        <footer class="panel-footer">
            <div class="row">
                <div class="col-sm-offset-4 col-sm-4 text-center">
                    <small class="text-muted inline m-t-sm m-b-sm">显示第 {{startRow}} 至 {{endRow}} 项结果，共 {{totalItems}} 项</small>
                </div>
                <div class="col-sm-4 text-right text-center-xs">
                    <pagination boundary-links="true" total-items="totalItems" ng-model="currentPage"
                                ng-change="pageChanged()" max-size="{{maxPageRow}}" class="pagination-sm m-t-none m-b"
                                previous-text="上一页" next-text="下一页"
                                first-text="首页" last-text="尾页"></pagination>
                </div>
            </div>
        </footer>
    </div>
</div>